package interfaces.inputValidation;

import fileHandling.language.LanguageLoader;
import fileHandling.language.interfaces.Validation;

public class IntegerBoundsChecker implements InputChecker {
	
	protected int low, high;
	
	public IntegerBoundsChecker(int low, int high) {
		this.low = low;
		this.high = high;
	}
	
	@Override
	public boolean isValid(String input) {
		Integer number = null;
		try { number = new Integer(input); }
		catch(Exception e) { return false; }
		int n = number.intValue();
		
		return n >= low && n <= high;
	}
	
	@Override
	public String getDescription() {
		String only = LanguageLoader.get(Validation.OnlyValuesBetween);
		String and = LanguageLoader.get(Validation.and);
		String allowed = LanguageLoader.get(Validation.AreAllowed);
		return only + " " + low + "\n" + and + " " + high + " " + allowed;
	}
}